<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>VUE Template</title>
    <script type="text/javascript" src="../js/vue.js"></script>
    <style>
        *{
            margin-top: 20px;
        }
        .demo1{
            height:50px;
            background-color: aqua;   
        }
        .box1{
            padding:10px;
            background-color: coral;
        }
        .box2{
            padding:10px;
            background-color:chartreuse;
        }
        .list{
            width:200px;
            height:200px;
            background-color: burlywood;
            overflow: auto;
        }
        li{
            height:100px;
        }
    </style>
</head>
<body>
    <!-- 
        Vue中事件修饰符：
        1.Prevent:阻止默认事件
        2.stop:阻止事件冒泡
        3.once:事件只触发一次
        4.capture:使用事件捕获模式
        5.self:只有event.target是当前操作的元素时才触发事件
        6.passive:事件的默认行为立即执行，无需等待事件回调执行完毕
     -->
    <div id="root">
        <h1>Hi,{{name}}</h1>
        <a href="http://www.baidu.com" @click.prevent="showInfo">点击提示</a>
        <!-- 阻止冒泡 -->
        <div class="demo1" @click="showInfo">
            <button @click.stop="showInfo">点我提示（阻止冒泡）</button>
        </div>
        <!-- 事件只触发一次 -->
        <button @click.once="showInfo">点我提示（触发一次）</button>
        <!-- 使用事件捕获模式 -->
        <div class="box1" @click.capture="showMsg(1)">
            div1
            <div class="box2" @click="showMsg(2)">
                div2
            </div>
        </div>
        <!-- self -->
        <div class="demo1" @click.self="showInfo1">
            <button @click="showInfo1">点我提示（阻止冒泡）</button>
        </div>
        <!-- passive -->
        <ul class="list" @wheel.passive="demo">
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
        </ul>
    </div>
</body>
    <script type="text/javascript">
        
        const vm = new Vue({
            el:'#root',
            data:function(){
                return{
                    name:'trentwu'
                }
            },
            methods:{
                showInfo(e){
                    alert("hi");
                },
                showInfo1(e){
                    console.log(e.target);
                },
                showMsg(msg){
                    alert(msg);
                },
                demo(){
                    for (let i = 0; i < 30000; i++) {
                        console.log('#');
                    }
                    console.log("累坏了");
                }
            }
        })
    </script>
</html>